package com.miaow.service;

/**
 * @author HWZ
 * @date 2023年12月07日 20:04
 * @description
 */
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
public class HystrixMovieRecommendationService {
    private final MovieRecommendationService movieRecommendationService;

    @Autowired
    public HystrixMovieRecommendationService(MovieRecommendationService movieRecommendationService) {
        this.movieRecommendationService = movieRecommendationService;
    }

    @HystrixCommand(fallbackMethod = "getDefaultMovies")
    public List<String> getRecommendedMovies() {
        return movieRecommendationService.getRecommendedMovies();
    }

    public List<String> getDefaultMovies() {
        // 定义一个备选的电影列表
        return Arrays.asList("Default Movie 1", "Default Movie 2", "Default Movie 3");
    }
}
